/**公共接口API**/
import obj from '@/utils/request'
let {request,baseURL} = obj
//查询所有国家
export function getCoungries() {
  return request({
    url: '/common/countries',
    method: 'get',
  })
}
//查询某个国家下面的省份
export function getProvinces(conutryName) {
  return request({
    url: '/common/provinces/'+conutryName,
    method: 'get',
  })
}
//查询某个省份下面城市
export function getCities(province) {
  return request({
    url: '/common/cities/'+province,
    method: 'get',
  })
}

//添加商品图片
export function addImage(data) {
  return request({
    url: '/common/images',
    method: 'post',
    data,
  })
}

//获取指定商品图片
export function getImage(imageUrl) {
  return baseURL+'/common/images?imageUrl='+imageUrl
}
//删除指定商品图片
export function delImage(params) {
  return request({
    url: '/common/images',
    method: 'delete',
    params
  })
}
//获取支付方式，退款方式，支付状态
export function getDict(type) {
  return request({
    url: '/common/dict/'+type,
    method: 'get',
  })
}
//智能获取地址
export function getAddress(params) {
  console.log(params)
  params.address = encodeURI(params.address)
  // console.log(params.address)
  // const newParams = {
  //   address: encodeURI(params.address)
  // }
  // console.log(newParams)
  return request({
    url: '/common/address/clean',
    method: 'get',
    params
  })
}
//上传Log
export function getLog() {
  return baseURL.replace(/(http|https)/,'ws')+'/log'
}
//上传Log
export function getTime() {
  return baseURL.replace(/(http|https)/,'ws')+'/time'
}

